import * as echarts from 'echarts'

/**
 * 基础折线图
 * @param el
 * @param params
 * @author 赵京涛
 */
export const useLineEchartsHandler = (el, params) => {
  const myChart = echarts.init(el)
  const option = {
    color: params.color,
    xAxis: {
      type: 'category',
      data: params.xData,
      axisLabel: {
        textStyle: {
          fontSize: 10,
          color: '#fff'
        }
      },
    },
    tooltip: {
      trigger: 'axis',
      className: 'tooltipBox',
      textStyle: {
        color: 'white' // 设置字体颜色为白色  
      },
    },
    grid: {
      left: '3%',
      right: '3%',
      top: '5%',
      bottom: '2%',
      containLabel: true
    },
    yAxis: {
      type: 'value',
      axisLine: {
        show: false,
        lineStyle: {
          color: '#fff',
        }
      }
    },
    series: [
      {
        data: params.seriesData,
        type: 'line',
        smooth: true,
        itemStyle: {
          color: '#5b9cd6' // 这里设置转折点的图例点颜色为蓝色  
        },
        lineStyle: {
          color: '#5b9cd6'
        }
      }
    ]
  }
  option && myChart.setOption(option)
}
